package com.zuowei.ycy.user.adapter;

import android.content.Context;

import com.and.yzy.frame.adapter.AdapterCallback;
import com.and.yzy.frame.adapter.CommonAdapter;
import com.and.yzy.frame.adapter.ViewHolder;
import com.and.yzy.frame.view.button.SelectNumberButtonBase;
import com.zuowei.ycy.R;
import com.zuowei.ycy.user.domain.BusinessSortInfo;
import com.zuowei.ycy.user.view.CircleSelectNumberBtn;

import java.util.List;

/**
 * Created by yzy on 2016/4/27.
 */
public class ShopCarAdapter extends CommonAdapter<BusinessSortInfo> {

    public ShopCarAdapter(Context context, List<BusinessSortInfo> mDatas, int itemLayoutId, AdapterCallback adapterCallback) {
        super(context, mDatas, itemLayoutId, adapterCallback);
    }

    @Override
    public void convert(ViewHolder holder, final BusinessSortInfo item, final int positon) {

        holder.setTextViewText(R.id.tv_name,item.getGoods_name())
        .setTextViewText(R.id.tv_price, "￥" + item.getGoods_price())
        ;

        CircleSelectNumberBtn selectNumberBtn=holder.getView(R.id.btn_number);

        selectNumberBtn.setNum(item.getNumber() + "");

        if (item.getNumber()==0){
            selectNumberBtn.setBtn_downVisibility(false);
        }else {
            selectNumberBtn.setBtn_downVisibility(true);
        }

        selectNumberBtn.setNumberButtonListener(new SelectNumberButtonBase.NumberButtonListener() {
            @Override
            public void btnNumber(String num, boolean isAdd) {

                notifyDataSetChanged();
                item.setNumber(Integer.parseInt(num));
                adapterCallback.adapterInfotoActiity(positon,3);

            }
        });


    }
}
